#include<stdio.h>
//int main()
//{
//    printf("hello world\n");
//    return 0;
//}
#include<string.h>
#include<sys/types.h>
#include<dirent.h>
#include<stdlib.h>

int main(int argc , char* argv[])
{
    if(argc != 2)
    {
        fprintf(stderr , "Usage: %s <directory>\n" , argv[0]);
        exit(EXIT_FAILURE);
    }
    //打开目录 -> opendir
    DIR* dir = opendir(argv[1]);
    if(!dir)
    {
        perror("opendir");
        exit(EXIT_FAILURE);
    }

    struct dirent* entry;//读取dir 中的数据
    while((entry = readdir(dir)) != NULL)
    {
        if(strcmp(entry->d_name,".")==0 || strcmp(entry->d_name ,"..")==0)
        {
            continue;
        }
        printf("Filenme : %s , Inode : %lu\n" ,entry->d_name ,(unsigned long)entry->d_ino);//打印
    }
    //关闭目录
    closedir(dir);
    printf("hello\n");
    return 0;
}
